﻿@model CmsMediaModel
           
@{
    Layout = "~/Templates/BaseAdminTemplate.cshtml";
    ResFile = "cms_Media";
}

@{
    var searchQuery = ViewBag.MediaSearchQuery;
    var isPartialContent = ViewBag.IsPartialContent != null && (bool) ViewBag.IsPartialContent;
    ViewBag.Title = _("{0} content", Model.CmsMedia != null ? Model.CmsMedia.FolderName : _("Search"));
}

<p><a class="b-back-link" href="/admin/cmsmedia"><i class="b-icon"></i> @_("Back to Media")</a></p>

<h1 class="g-clear">
    <i class="b-icon b-icon_h b-icon_h_media"></i>
    <span class="b-overflow">
	    
        @if (Model.CmsMedia != null)
        {
            @Model.CmsMedia.FolderName
            if (Model.CmsMedia.Description != null)
            {<span class="b-intro-text">@Model.CmsMedia.Description</span>}
            <span class="b-intro-text"><a href="@Url.Action("edit", "cmsmedia", new { id = Model.CmsMedia.Id })">@_("Edit folder")</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="@Url.Action("index", "cmsmediacontenttag")">@_("Edit tags")</a></span>    
        }
        else
        {
            <span>@_("Search results")</span>
        }
	    
    </span>  
</h1>



    <div class="b-buttons float-left">
        <a class="b-button" href="@Url.Action("add", "cmsmediacontent", Model.CmsMedia != null ? new { id = Model.CmsMedia.Id } : null)">@_("Upload new item")</a>    
        <a class="b-button" href="@Url.Action("add", "cmsmedia", Model.CmsMedia != null ? new { parentId = Model.CmsMedia.Id } : null)">@_("Create New Folder")</a>    
    </div>

<form method="GET" action="@Url.Action("Get", "CmsMedia")">
    <div class="b-form b-form_filter">
	    <ol class="b-form__rows ul-reset g-clear">
            <li class="b-form__row g-clear">
                <input type="text" name="searchQuery" value="@(searchQuery)" placeholder="@_(CmsAdminSearchSnippetModel.EntryText)" class="text" />
                <input type="hidden" name="Id" value="@(Model.CmsMedia != null ? Model.CmsMedia.Id.ToString() : "")" />

                @Html.DropDownList("orderBy", ViewBag.OrderBySelectList as SelectList)                
                <input type="submit" value="@_("Search")" class="b-button b-button_small b-button_colour_grey" />
            </li>
	    </ol>
    </div>
</form>


@if (Model.SubFolders != null)
{
<div class="sub-folders">
    <h2>@_("Sub-folders")</h2>
    @Html.Partial("MediaFolders", Model.SubFolders)	
</div>
}

    <h2 class="float-left">@_("Media Items")</h2>
@if (Model.CmsMedia != null && isPartialContent)
{
        <a href="@Url.Action("Get", "CmsMedia", new { id = Model.CmsMedia.Id })" class="b-back-link float-left">@_("Show all contents of this folder")</a>    
}

@if (Model.Contents != null && Model.Contents.Count > 0)
{

    using (Html.BeginForm("action", "cmsmediacontent"))
    {    
            <div class="b-form b-form_searchmedia float-right">
                <ol class="b-form__rows ul-reset g-clear">
                    <li class="b-form__row b-form__row_checkbox b-form__row_assets g-clear">
                        <input class="b-checkbox b-checkbox-mediacontent-selectall" type="checkbox" id="selectAll" />
                        <label for="selectAll">@_("Select all")</label>
                        <select id="mediaContentCases" name="Action">
                            <option value="" selected="selected"></option>
                            <option value="@CmsAdminMediaActionModel.ActionDelete">@_("Delete")</option>
                        </select>
                        <input id="mediaContentAction" class="b-button" type="submit" value="@_("Apply")" />	
                    </li>
                </ol>
            </div>

            <input type="hidden" name="Id" value="@(Model.CmsMedia != null ? Model.CmsMedia.Id.ToString() : "")" />
        if (!string.IsNullOrEmpty(searchQuery))
        {
            <div style="clear:left">
                @__("{0} media file found for '{1}'", "{0} media files found for '{1}'", Model.Contents.Count, Model.Contents.Count, searchQuery)                
            </div>
        }
@Html.Partial("CmsPager", new { PageSize = 32, Url = "/admin/cmsmedia/get/" + (Model.CmsMedia != null ? Model.CmsMedia.Id.ToString() : ""), TotalCount = Model.Contents.Count }.ToExpando())
@Html.Partial("MediaContentList", Model.Contents.Take(32))
@Html.Partial("CmsPager", new { PageSize = 32, Url = "/admin/cmsmedia/get/" + (Model.CmsMedia != null ? Model.CmsMedia.Id.ToString() : ""), TotalCount = Model.Contents.Count }.ToExpando())
    }
}
else
{
    if (!string.IsNullOrEmpty(searchQuery))
    {
        <p class="clear">@_("No results found for '{0}'", searchQuery)</p>
    }
    else
    {
        <p class="clear">@_("No media content")</p>        
    }
}

@section scriptBlock{
    <script type="text/javascript">
    // <![CDATA[
        $(document).ready(function () {
            $(".b-fancybox").fancybox({
                'titlePosition' : 'inside',
                'transitionIn'	: 'none',
                'transitionOut'	: 'none'	
            });
            blocksHeight(".b-assets", ".b-assets-item");
        });
    // ]]>
    </script>
    
    <script type="text/javascript" src="@Url.Content("/admin/assets/js/special/jquery.zclip.js")"></script>
}